﻿//===============================================================================
// Microsoft Innovation Centre - Western Europe
// Copyright (c) 2008 Microsoft Corporation. All rights reserved.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using Microsoft.Practices.Composite.Events;
using Microsoft.WVB.Framework;
using Microsoft.WVB.Framework.DataServicesEntities;
using Microsoft.WVB.Silverlight.Infrastructure;

namespace Microsoft.WVB.UI
{
    public partial class CarouselView : UserControl
    {
        public CarouselModel ViewModel { get; private set; }

        public CarouselView()
        {
            if (!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this))
            {
                ViewModel = IoC.Create<CarouselModel>();
                DataContext = ViewModel;
            }

            InitializeComponent();
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;
            RadialPanel rp = null;
            UIElement uie = sender as UIElement;

            while (uie != null)
            {
                uie = VisualTreeHelper.GetParent(uie) as UIElement;
                rp = uie as RadialPanel;
                if (rp != null)
                {
                    rp.Spin(b, rp);
                    break;
                }
            }

            //Update Broadcaster channelinfo

            IEventAggregator ag = IoC.GetCreate<IEventAggregator>();
            ag.GetEvent<ExplorerMinimizeEvent>().Publish(this);

            Broadcaster bc = (Broadcaster)b.DataContext;
            currentBroadcasterInfo.DataContext = bc;
        }
    }
}
